﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class XemDonHang : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string ma = Request.QueryString["code"];
        string sql = "SELECT [IDDonDatHang] [code], (SELECT [UserName] From [aspnet_Users] WHERE UserId = '561a8afc-78f9-4896-82ca-c6838d84f335') as [IDUser], [ThoiDiemLapDDH], [TongTien], [SoDienThoaiNguoiNhan], [DiaChiGiaoHang], [EmailNguoiNhan], [TrangThai]  FROM [DonDatHang] WHERE code = '" + ma + "'";
        SqlDataSource2.SelectCommand = sql;

        
        
        ListView2.DataSource = SqlDataSource2;
        ListView2.DataBind();

        DataView dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty);
        string ID = dv.Table.Rows[0][0].ToString();

        SqlDataSource1.SelectCommand = "SELECT [IDChiTietDDH], ( select TenTL FROM [TaiLieu] where [TaiLieu].IDTaiLieu = [ChiTietDDH].IDTaiLieu ) as [IDTaiLieu], [SoLuong], [DonGia] FROM [ChiTietDDH] WHERE IDDonDatHang = '" + ID + "'";
        ListView1.DataSource = SqlDataSource1;
        ListView1.DataBind();
    }

    public string format_text(string i)
    {
        string aa = "";

        if (i.CompareTo("0") == 0)
            aa = "Chưa duyệt";
        else
            if (i.CompareTo("1") == 0)
                aa = "Đang giao hàng";
            else
                aa = "Đã nhận tiền";
        return aa;
    }
   
}